<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
	<script src="//cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
	<script src="templates.js"></script>
	<script src="ionic-datepicker.bundle.min.js"></script>
	<link rel="stylesheet" href="//cdn.bootcss.com/ionic/1.3.2/css/ionic.min.css">
	<link rel="stylesheet" href="style.css">
	<script>
		var test = angular.module('test', ['ionic','ionic-datepicker']);
		test.config(function (ionicDatePickerProvider) {
		    var datePickerObj = {
		      inputDate: new Date(),
		      titleLabel: 'Select a Date',
		      setLabel: 'Set',
		      todayLabel: 'Today',
		      closeLabel: 'Close',
		      mondayFirst: false,
		      weeksList: ["S", "M", "T", "W", "T", "F", "S"],
		      monthsList: ["Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"],
		      templateType: 'popup',
		      from: new Date(2012, 8, 1),
		      to: new Date(2018, 8, 1),
		      showTodayButton: true,
		      dateFormat: 'dd MMMM yyyy',
		      closeOnSelect: false,
		      disableWeekdays: []
		    };
		    ionicDatePickerProvider.configDatePicker(datePickerObj);
		});
		test.controller("testCtrl",["$scope","ionicDatePicker",function( $scope,ionicDatePicker ){
			var ipObj1 = {
		      callback: function (val) {  //Mandatory
		        console.log('Return value from the datepicker popup is : ' + val, new Date(val));
		      },
		      disabledDates: [            //Optional
		        new Date(2016, 2, 16),
		        new Date(2015, 3, 16),
		        new Date(2015, 4, 16),
		        new Date(2015, 5, 16),
		        new Date('Wednesday, August 12, 2015'),
		        new Date("08-16-2016"),
		        new Date(1439676000000)
		      ],
		      from: new Date(2012, 1, 1), //Optional
		      to: new Date(2016, 10, 30), //Optional
		      inputDate: new Date(),      //Optional
		      mondayFirst: true,          //Optional
		      disableWeekdays: [0],       //Optional
		      closeOnSelect: false,       //Optional
		      templateType: 'popup'       //Optional
		    };

		    $scope.openDatePicker = function(){
		      ionicDatePicker.openDatePicker(ipObj1);
		    };
		}]);

		 // test.controller("testCtrl",["$scope","$ionicPopup","$timeout",function( $scope,$ionicPopup,$timeout ){
		 // 	$scope.hello = "world";
		 // 	$scope.data = {};
		 // 	// An elaborate, custom popup
			//   var myPopup = $ionicPopup.show({
			//     template: '<input type="password" ng-model="data.wifi">',
			//     title: 'Enter Wi-Fi Password',
			//     subTitle: 'Please use normal things',
			//     scope: $scope,
			//     buttons: [
			//       { text: 'Cancel' },
			//       {
			//         text: '<b>Save</b>',
			//         type: 'button-positive',
			//         onTap: function(e) {
			//           if (!$scope.data.wifi) {
			//             //don't allow the user to close unless he enters wifi password
			//             e.preventDefault();
			//           } else {
			//             return $scope.data.wifi;
			//           }
			//         }
			//       }
			//     ]
			//   });

			//   myPopup.then(function(res) {
			//     console.log('Tapped!', res);
			//   });

			//   $timeout(function() {
			//      myPopup.close(); //close the popup after 3 seconds for some reason
			//   }, 3000);

		 // }]);
		angular.element(document).ready(function(){
			angular.bootstrap(document.getElementsByTagName("body")[0],['test']);
		});
	</script>
</head>
<body ng-controller="testCtrl">
	<button ng-click="openDatePicker()">hello</button>
	{{ hello }}
</body>
</html>